package mse.eai.esb;

import java.util.HashMap;


import org.jboss.logging.Logger;
import org.jboss.soa.esb.actions.ActionLifecycle;
import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;

public class PrepareCallILotteryGetActiveLottery implements ActionLifecycle {

	private static final Logger log = Logger.getLogger(PrepareCallILotteryGetActiveLottery.class);
	
	@Override
	public void destroy() throws ActionLifecycleException {
		// TODO Auto-generated method stub

	}

	@Override
	public void initialise() throws ActionLifecycleException {
		// TODO Auto-generated method stub

	}

	public PrepareCallILotteryGetActiveLottery(ConfigTree config) {

	}

	public Message process(Message m) {

		log.info(" ### DEIXA PASSAR A MENSAGEM ###");
		
		System.out.println("-----------------ANTES ");
		Body b = m.getBody();
		for (String str : b.getNames()) {
			System.out.println(str + " = " + b.get(str));
		}
		

		
		HashMap requestMap = new HashMap();
		requestMap.put("getActiveLottery.arg0", "");

		m.getBody().add(requestMap);
		
		System.out.println("-----------------DEPOIS ");
		b = m.getBody();
		for (String str : b.getNames()) {
			System.out.println(str + " = " + b.get(str));
		}
		

		log.info(" ### MENSAGEM PASSOU ###");

		return m;

	}
}
